//
//  TLMoreCommentCell.m
//  Coding_iOS
//
//  Created by taolei-mac on 2017/11/30.
//  Copyright © 2017年 com.lianchuan. All rights reserved.
//

#import "TLMoreCommentCell.h"

@interface TLMoreCommentCell ()

@property (nonatomic, weak) UIButton *checkButton;

@end

@implementation TLMoreCommentCell

+ (instancetype)createMoreCommentCellWithTableView:(UITableView *)tableView
{
    static NSString *Id = @"moreComment";
    TLMoreCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:Id];
    if(!cell){
        
        cell = [[TLMoreCommentCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Id];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.backgroundColor = [UIColor colorWithHexString:@"0xF2F4F6"];
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        
        UIButton *checkButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [checkButton setTitleColor:[UIColor colorWithHexString:@"0x425063"] forState:UIControlStateNormal];
        checkButton.titleLabel.font = [UIFont systemFontOfSize:14];
        [checkButton setImage:[UIImage originImageWithName:@"tweet_more_comment_icon"] forState:UIControlStateNormal];
        [checkButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 10)];
        [self.contentView addSubview:checkButton];
        self.checkButton = checkButton;
    }
    return self;
}

- (void)setCount:(NSInteger)count
{
    _count = count;
    
    [self.checkButton setTitle:[NSString stringWithFormat:@"查看全部%zd条评论", count] forState:UIControlStateNormal];
    [self.checkButton.titleLabel sizeToFit];
    CGFloat checkButtonW = self.checkButton.currentImage.size.width + 10 + self.checkButton.titleLabel.width;
    self.checkButton.frame = CGRectMake(10, 10, checkButtonW, 20);
}

@end
